<?php

class VES_VendorsWarehouse_Block_Confirmation_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('confirmation_orderGrid');
        $this->setDefaultSort('created_at');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
		
    }
	
    protected function _prepareCollection()
    {
		$vendorId = Mage::getSingleton('vendors/session')->getVendor()->getId();
        $collection = Mage::getResourceModel('sales/order_item_collection')->addFieldToFilter('vendor_id', $vendorId);
		$collection->getSelect()->group(array('vendor_id', 'order_id'));
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
    protected function _prepareColumns()
    {
        $this->addColumn('created_at', array(
          'header'    => $this->__('Purchased On'),
          'align'     => 'right',
          'type'      => 'datetime',
          'format'	  => 'Y-M-d H:m:s',
          'index'     => 'created_at',
		));
        $this->addColumn('order_id', array(
            'header'	=> $this->__('Order No.'),
            'align'		=> 'right',
            'index'		=> 'order_id',
			'renderer'	=> 'VES_VendorsWarehouse_Block_Widget_Grid_Column_Renderer_Order',
        ));
		$this->addColumn('status', array(
            'header'	=> $this->__('Status'),
            'align'		=> 'right',
            'index'		=> 'order_id',
			'renderer'	=> 'VES_VendorsWarehouse_Block_Widget_Grid_Column_Renderer_Status',
        ));
		

        $this->addColumn('action', array(
                'header'    =>  $this->__('Action'),
                'type'      => 'action',
				'width'		=> '120px',
				'align'		=> 'right',
                'filter'    => false,
                'sortable'  => false,
                'index'     => 'stores',
                'is_system' => true,
				'renderer'  => 'VES_VendorsWarehouse_Block_Widget_Grid_Column_Renderer_Actions',
        ));
        
        return parent::_prepareColumns();
    }

    public function getRowUrl($row)
    {
        // return $this->getUrl('*/*/confirm', array('id' => $row->getOrderId()));
		return false;
    }

}
